package cn.tedu.csmall.product.controller;

import cn.tedu.csmall.product.pojo.dto.CategoryAddNewDTO;
import cn.tedu.csmall.product.service.ICategoryService;
import cn.tedu.csmall.product.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/category")
@Api (tags = "04 分类属性模板")
public class CategoryController {
    @Autowired
    ICategoryService categoryService;

    @PostMapping("/add-new")
    @ApiOperation("添加分类")
    @ApiOperationSupport(order = 100)
    public JsonResult addNew(CategoryAddNewDTO categoryAddNewDTO){
        log.debug("开始处理属性模板[添加分类模板]的请求,参数:{}",categoryAddNewDTO);
        categoryService.addNew(categoryAddNewDTO);
        return JsonResult.ok();
    }

    @PostMapping("/delete")
    @ApiOperation("删除分类")
    @ApiOperationSupport(order = 200)
    public JsonResult delete(Long id){
        log.debug("开始处理属性模板[删除分类模板]的请求,参数:{}",id);
        categoryService.delete(id);
        return JsonResult.ok();
    }
}
